package logic

import (
	"context"

	"user/internal/svc"
	"user/pb/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetUserListByIDsLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGetUserListByIDsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserListByIDsLogic {
	return &GetUserListByIDsLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// GetUserListByIDs 获取用户列表
func (l *GetUserListByIDsLogic) GetUserListByIDs(in *user.UserListByIDsRequest) (*user.UserListResponse, error) {
	list, total, err := l.svcCtx.UserExtendModel.FindListByIDs(l.ctx, in.Ids)
	if err != nil {
		return nil, err
	}

	var data []*user.UserInfo
	for _, item := range list {
		data = append(data, &user.UserInfo{
			Id:   item.Id,
			Name: item.Name,
			//Mobile:   item.Mobile,
			//Email:    item.Email,
			Avatar: item.Avatar,
			//Status:   item.Status,
			//CreateAt: item.CreatedAt.Unix(),
			//UpdateAt: item.UpdatedAt.Unix(),
		})
	}
	return &user.UserListResponse{Total: total, Data: data}, nil
}
